package com.huang.controller;

import com.huang.entity.Product;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Value("${server.port}")
    private int port;


    @GetMapping("/showMsg")
    public String showMessage(){
        System.out.println("进入商品服务");
        return "这是商品信息"+port;
    }

    @GetMapping("/showMsgTestGetParam")
    public String showMessageGetParam(String msg){
        System.out.println("进入商品服务");
        return "商品服务收到"+msg+"商品服务端口:"+port;

    }

    @PostMapping("/addProduct")
    public Map<String,Object> addProduct(@RequestBody Product product){
        System.out.println(product);
        HashMap<String, Object> res = new HashMap<>();
        res.put("code",200);
        res.put("product",product);
        res.put("msg","ok");
        return res;
    }
}
